package com.gayworld.model.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.gayworld.model.entity.Rate;

@Repository
public class RateDAOImpl extends HibernateBaseDAO<Rate> implements RateDAO {

	@Override
	public List<Rate> getRatesByPlaceId(Integer placeId) {

		Criteria criteria = getSession().getCurrentSession().createCriteria(
				Rate.class);
		// DetachedCriteria criteria = DetachedCriteria.forClass(Places.class);

		criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
		criteria.add(Restrictions.eq("place.id", placeId));
		/*
		 * criteria.setProjection(Projections.distinct(
		 * Projections.groupProperty("id")));
		 */
	//	criteria.setMaxResults(maxResult);

		return criteria.list();

	}

}
